<?php
namespace app\index\controller;

use app\index\validate\Member as memberValidate;
use app\index\model\Member as memberModel;
use think\captcha\Captcha;
use think\Db;
use think\Request;

class Member extends Base
{
    public function add(){
        return $this->fetch('add');
    }

    public function insert()
    {
        $memberModel = new memberModel();
        $val = new memberValidate();
        $data = input('post.');
        if(!$val->check($data)){
            $this->error($val->getError());
        }
        $ret = $memberModel->allowField(true)->save($data);
        dump($ret);
    }
    public function memberList(Request $request)
    {
        $list = Db::name('member')->where('status',1)->paginate(1,false,[
            'var_page' => 'p',
            'query'=> $request->param(),
        ]);
        $page = $list->render();
        // 模板变量赋值
        $this->assign('list', $list);
        $this->assign('page', $page);
        return $this->fetch('memberList');
    }



    public function verify()
    {
        $captcha = new Captcha();
        return $captcha->entry();
    }


}